package com.das.mechanic_base.widget;

import android.content.Context;
import android.view.ViewTreeObserver;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.das.mechanic_base.R;
import com.das.mechanic_base.base.X3BaseBottomSheetDialog;

public class X3BottomTaskDialog extends X3BaseBottomSheetDialog {

    private TextView tx_date_tv;
    private TextView tx_date_tv_two;
    private RelativeLayout rll_tilte_style;

    public X3BottomTaskDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected boolean getDialogCancel() {
        return false;
    }

    @Override
    protected void initView() {
        tx_date_tv = findViewById(R.id.tx_date_tv);
        tx_date_tv_two = findViewById(R.id.tx_date_tv_two);
        rll_tilte_style = findViewById(R.id.rll_tilte_style);
        tx_date_tv.setOnClickListener(v -> onClickItemBottom.getOnClickOne());

        tx_date_tv_two.setOnClickListener(v -> onClickItemBottom.getOnClickTwo());
        //获取控件的高度
        ViewTreeObserver vto2 = rll_tilte_style.getViewTreeObserver();
        vto2.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                rll_tilte_style.getViewTreeObserver().removeGlobalOnLayoutListener(this);
//                if (ScreenUtils.getVirtualBarHeight(mContext) > 0) {
//                    setDialogWindowAttr(rll_tilte_style.getMeasuredHeight() );
//                }else {
//                }
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.x3_dialog_task;
    }

    OnClickItemBottom onClickItemBottom;

    public interface OnClickItemBottom {
        void getOnClickOne();

        void getOnClickTwo();
    }

    public void setOnClickItemBottom(OnClickItemBottom onClickItemBottoms) {
        this.onClickItemBottom = onClickItemBottoms;
    }

}
